//
//  XLHTTPSessionManager+CashOut.m
//  XiangLove
//
//  Created by 陈宪栋 on 2018/1/2.
//  Copyright © 2018年 BAOMIHUA.COM. All rights reserved.
//

#import "XLHTTPSessionManager+CashOut.h"
#import "XLAccountManager.h"
#import "XLUserInfoModel.h"
#import "BMHWithdrawalListModel.h"

@implementation XLHTTPSessionManager (CashOut)
- (RACSignal *)getContractStatusWithUserId:(NSString *)userId {
    NSString *URLString = @"/Api/v1/Gongmao/GetContractStatus";
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setObject:userId ?: @"" forKey:@"userId"];
    
    [self.requestSerializer setValue:[[XLAccountManager shareInstance] model].SecretKey forHTTPHeaderField:@"sign"];
    return [self GET:URLString parameters:parameters resultClass:nil];
}

- (RACSignal *)signWithUserId:(NSString *)userId name:(NSString *)name mobile:(NSString *)mobile idNumber:(NSString *)idNumber bankName:(NSString *)bankName bankNum:(NSString *)bankNum {
    NSString *URLString = @"/Api/v1/Gongmao/SignAContract";
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setObject:userId ?: @""     forKey:@"userId"];
    [parameters setObject:name ?: @""       forKey:@"name"];
    [parameters setObject:mobile ?: @""     forKey:@"mobile"];
    [parameters setObject:idNumber ?: @""   forKey:@"idNumber"];
    [parameters setObject:bankName ?: @""   forKey:@"bankName"];
    [parameters setObject:bankNum ?: @""    forKey:@"bankNum"];
    [self.requestSerializer setValue:[[XLAccountManager shareInstance] model].SecretKey forHTTPHeaderField:@"sign"];
    return [self GET:URLString parameters:parameters resultClass:nil];
}

- (RACSignal *)getWithholdingMoneyWithUserId:(NSString *)userId money:(NSString *)money {
    NSString *URLString = @"/Api/v1/Gongmao/GetWithholdingMoney";
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setObject:userId ?: @"" forKey:@"userId"];
    [parameters setObject:money ?: @""  forKey:@"money"];
    [self.requestSerializer setValue:[[XLAccountManager shareInstance] model].SecretKey forHTTPHeaderField:@"sign"];
    return [self GET:URLString parameters:parameters resultClass:nil];
}

- (RACSignal *)cashOutWithUserId:(NSString *)userId money:(NSString *)money {
    NSString *URLString = @"/Api/v1/Gongmao/WithdrawDeposit";
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setObject:userId ?: @"" forKey:@"userId"];
    [parameters setObject:money ?: @""  forKey:@"money"];
    [self.requestSerializer setValue:[[XLAccountManager shareInstance] model].SecretKey forHTTPHeaderField:@"sign"];
    return [self GET:URLString parameters:parameters resultClass:nil];
}

- (RACSignal *)getCashOutRecordWithUserId:(NSString *)userId year:(NSString *)year month:(NSString *)month pageIndex:(NSInteger)pageIndex {
    NSString *URLString = @"/Api/v1/Gongmao/WithdrawDepositRecord";
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setObject:userId ?: @"" forKey:@"userId"];
    [parameters setObject:year ?: @""   forKey:@"year"];
    [parameters setObject:month ?: @""  forKey:@"month"];
    [parameters setObject:@(pageIndex)  forKey:@"pageIndex"];
    [self.requestSerializer setValue:[[XLAccountManager shareInstance] model].SecretKey forHTTPHeaderField:@"sign"];
    return [self POST:URLString parameters:parameters resultClass:[BMHWithdrawalListModel class]];
}

- (RACSignal *)getMonthWithdrawDepositMoneyWithUserId:(NSString *)userId {
    NSString *URLString = @"/api/v1/Gongmao/GetMonthWithdrawDepositMoney";
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    [parameters setObject:userId ?: @"" forKey:@"userId"];
    [self.requestSerializer setValue:[[XLAccountManager shareInstance] model].SecretKey forHTTPHeaderField:@"sign"];
    return [self GET:URLString parameters:parameters resultClass:nil];
}
@end
